﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ViewModel
{
    public class Issue
    {
        public int ID { get; set; }
        public string Name { get; set; }
        public string Description { get; set; }
        public bool IsRequest { get; set; }
        public Priority Priority { get; set; }        
        public Status Status { get; set; }
        public DateTime DateCreated { get; set; }
        public DateTime DateStart { get; set; }
        public DateTime DateEnd { get; set; }
        public DateTime? DateCompleted { get; set; }
        public int UDF1 { get; set; }
        public string UDF2 { get; set; }

        public List<Shop> Assignee { get; set; }
        public List<Comment> Comments { get; set; }

        public string DisplayText { get { return string.Format("#{0} {1}", ID, Name); } }
        public string DisplaySearchText { get { 
            return string.Format("#{0} {1} [Priority: {2} From: {3} To: {4} Assignee: {5}]",
                ID,
                Name,
                Priority,
                DateStart.ToString(),
                DateEnd.ToString(),
                Assignee.FirstOrDefault().Name);
        } }
        public string DisplayDateRange { get { return string.Format("From: {0} - To: {1}", DateStart.ToShortDateString(), DateEnd.ToShortDateString()); } }
        public int ShopID { get { return Assignee.Count > 0 ? Assignee.FirstOrDefault().ID : 0; } }
        public string ShopName { get { return Assignee.Count > 0 ? Assignee.FirstOrDefault().Name : ""; } }        
    }
}
